#include<stdio.h>
#include<stdlib.h>

#define BUFFSIZE 1024
//fgets和fputs操作文本文件，操作二进制文件是不对的！fputc和fgetc也不能操作二进制文件
int main(int argc,char **argv)
{
    char buf[BUFFSIZE];
    int n;
    if (argc < 3)
    {
        fprintf(stderr,"Usage: %s source_file dest_file\n",argv[0]);
        exit(1);
    }

    FILE *fps;
    FILE *fpd;

    fps = fopen(argv[1],"r");
    if (fps == NULL)
    {
        perror("fopen()");
        exit(1);
    }
    fpd = fopen(argv[2],"w");
    if (fpd == NULL)
    {
        fclose(fps);
        perror("fopen()");
        exit(1);
    }

    while ((n=fread(buf,1,BUFFSIZE,fps)) > 0)
    {
        fwrite(buf,1,n,fpd);
    }
    
    fclose(fps);
    fclose(fpd);
    exit(0);
}